﻿{extend name="common/base"}
{block name="title"}我的优惠卷{/block}

<body>

{block name="content"}

	<!-- product list -->
	<div class="product-list segments-page" style="margin: 0px auto">
		<div class="container" style="margin: 0px auto">
			<div class="content no-bb">
				<div class="pages-title">
					<h4>我的订单</h4>
				</div>
				{foreach name="list" id="fo"}
				<div class="content no-bb">
					<p>订单号：{$fo.zhifu_id}</p>
					<p>付款时间：{$fo.dingdan_time}</p>
					<p>总计：￥{$fo.total_money}</p>
					{foreach name="fo['son']" id="fs"}
					<div class="product-image" style="clear:both">
						<a href="{:Url('product/product_details')}?id={$fs.goods_id}">
						<img src="{$fs['thumb_src'][0]}" alt="">
						</a>
					</div>
					<div class="product-text" style="float:left">
						<a href="{:Url('product/product_details')}?id={$fs.goods_id}"><p>{$fs.name}</p></a>
						<p>{$fs.guigetypeName} , 数量：{$fs.num}</p>
						<p>单价：￥{$fs.price}</p>
						{switch name="fo.fahuo_status"}
							{case value="0"}<h5>未发货</h5>{/case}
							{case value="1"}<h5>已发货</h5>{/case}
						{/switch}
						<br>
					</div>
					{/foreach}
					<div class="clear"></div>
					{switch name="fo.queren_status"}
						{case value="0"}<button class="button" onclick="showQueren(this)" id="shouhuo">确认收货
							<input type="hidden" value="{$fo.id}">
						</button>{/case}
						{case value="1"}<button class="button">已收货</button>{/case}
					{/switch}
					<button class="button">申请退货</button>
				</div>
				<div class="pages-title"></div>
				{/foreach}
			</div>			
		</div>
	</div>
	<!-- end product list -->

	<!-- BEGIN 确认收货窗口 --> 
	<div id="queren-box-div" class="">
		<div class="queren-box-item">
			<div class="queren-box-item-title" style="text-align: left;padding-left: 10px;width:100%;height:30%;">确认收货？</div>
			<div style="margin-top:5%;height:70%;">
				<button style="width:40%;height:35px;background:rgb(156, 156, 149);color:#fff;" onclick="hideQuxiao();">取消</button>
				<button style="margin-left:5px;width:40%;height:35px;background:rgb(247, 19, 38);color:#fff;" onclick="querenSure(this)">确定</button>
			</div>
		</div>
	</div>
	<!-- END 确认收货窗口 -->
{/block}

{block name="footjs"}
<script type="text/javascript">
    
	function hideQuxiao()
	{
        $('#queren-box-div').fadeOut();
        
	}
	function showQueren(obj)
	{
        $('#queren-box-div').fadeIn();
        var dingdanID = $(obj).find('input').val();
	    $('#queren-box-div').attr('class','querenBox'+dingdanID);
    }
    function querenSure(obj){
        var dingdanID = $(obj).parent().parent().parent().attr("class").substring(9);        
        $.ajax({
            url:"{:url('index/user/shouhuo')}",
            type:"post",
            data:{dingdan_id:dingdanID},
            dataType:"json",
            success:function(ret){                
                console.log(ret)
                if(ret.data==1){
					$('#queren-box-div').fadeOut();
                	$("#shouhuo").html('已收货');
					$("#shouhuo").attr('disabled','disabled');
				}
            }
        });
    }
</script>
{/block}
